<?php

class FormPushButton extends FormControl {

	public static $property = array(
		'wbtype',
		'name',
		'caption',
		'x',
		'y',
		'width',
		'height',
		'disabled',
		'border',
		'visible'
	);	
	
	public function __construct() { 
		parent::__construct(array(
			'wbtype' => 'PushButton',
			'x' => 0,
			'y' => 0,
			'width' => 100,
			'height' => 30,
			'caption' => 'empty button',
			'style' => wbconstant('center middle'),
			'line' => 1
		));
	}


	/**
	 * 컨트롤 그리기 
	 * 
	 * @param WBGraphics $graphics
	 */
	public function displayControl(WBGraphics $g) {
		
		$font = ($this['disabled']) ? self::$disabledFont : self::$realFont ;

		$xstart = $this->getOption('x');
		$ystart = $this->getOption('y');
		$width = $this->getOption('width');
		$height = $this->getOption('height');		
		$caption = $this->getOption('caption');		
				
		$xcenter = $xstart + $width / 2;
		$xend = $xstart + $width;
		$ymiddle = $ystart + $height / 2;
		$yend = $ystart + $height;	

		$style = WBC_CENTER | WBC_MIDDLE;

		if ($this['disabled']) { 
			$g->rect($xstart, $ystart, $width, $height, FormControl::FACE, true);
			$g->line($xend - 2, $ystart, $xend - 2, $yend - 2, FormControl::FACE);
			$g->line($xstart, $yend - 2, $xend - 2, $yend - 2, FormControl::FACE);
			$g->line($xstart, $ystart, $xend - 2, $ystart, FormControl::HILITE);
			$g->line($xstart, $ystart, $xstart, $yend - 2, FormControl::HILITE);
			$g->line($xend - 1, $ystart, $xend - 1, $yend - 1, FormControl::SHADE);
			$g->line($xstart, $yend - 1, $xend - 2, $yend - 1, FormControl::SHADE);
			$g->text($caption, $xstart + 1, $ystart + 1, $width, $height, $font, $style);
			$g->text($caption, $xstart, $ystart,  $width, $height, $font, $style);
			
		} else { 
			$g->rect($xstart, $ystart, $width, $height, FormControl::FACE, true);
			$g->line($xend - 2, $ystart, $xend - 2, $yend - 2, FormControl::SHADE);
			$g->line($xstart, $yend - 2, $xend - 2, $yend - 2, FormControl::SHADE);
			$g->line($xstart, $ystart, $xend - 2, $ystart, FormControl::HILITE);
			$g->line($xstart, $ystart, $xstart, $yend - 2, FormControl::HILITE);
			$g->line($xend - 1, $ystart, $xend - 1, $yend - 1, FormControl::SHADOW);
			$g->line($xstart, $yend - 1, $xend - 2, $yend - 1, FormControl::SHADOW);
			$g->text($caption, $xstart, $ystart, $width, $height, $font, $style);
		}
	}
	
	public function getProperty() { 
		return self::$property;
	}	
}


?>